/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.esakk001;

import idea.model.qnrlibrary.Categories;
import java.beans.IntrospectionException;
import java.util.List;
import org.openide.nodes.ChildFactory;
import org.openide.nodes.Node;
import org.esakk001.CategoriesNode;
import org.openide.nodes.BeanNode;
import org.openide.util.Exceptions;

/**
 *
 * @author esakk001
 */
 public class CategoriesFactory extends ChildFactory<Categories> {

        private List<Categories> resultList;

       

        public CategoriesFactory(List<Categories> cpList) {
            this.resultList = cpList;
        //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

      

        @Override
        protected boolean createKeys(List<Categories> list) {
            for (Categories cp : this.resultList) {
                list.add(cp);
            }
            return true;//To change body of generated methods, choose Tools | Templates.
        }

        /**
     *
     * @param cp
     * @return
     */
    @Override
        protected Node createNodeForKey(Categories cp) {
         try {
             return new BeanNode(cp);
            //    return null;;
    //            try
    //            {
    //                return new BeanNode( cp );
    //            }
    //            catch ( IntrospectionException ex )
    //            {
    //                Exceptions.printStackTrace( ex );
    //            }
    //            }
         } catch (IntrospectionException ex) {
             Exceptions.printStackTrace(ex);
         }
         return null;
        }

   
    }

